#include <gtest/gtest.h>
#include "axisgroup/axisgroup_robot.h"
#include "axisgroup/robot_mgr.h"
using namespace axisgroup;

class AxisGroupMgrTest : public ::testing::Test
{
protected:
    virtual void SetUp() override {}
    virtual void TearDown() override { AxisGroupMgr::instance().reset(); }
};

TEST_F(AxisGroupMgrTest, add)
{
    auto ag = std::make_shared<Robot>();
    ASSERT_EQ(AxisGroupMgr::instance().add_axisgroup(ag), 0);
    ASSERT_EQ(AxisGroupMgr::instance().add_axisgroup(ag), -1);
    auto agg = AxisGroupMgr::instance().get_axisgroup(0);
    ASSERT_EQ(agg.get(), ag.get());

    auto ag2 = std::make_shared<Robot>(12100001);
    ASSERT_EQ(AxisGroupMgr::instance().add_axisgroup(ag2), 0);
    auto agg2 = AxisGroupMgr::instance().get_axisgroup(1);
    ASSERT_EQ(agg2.get(), ag2.get());
}

TEST_F(AxisGroupMgrTest, del)
{
    ASSERT_EQ(AxisGroupMgr::instance().del_axisgroup(0), -1);

    auto ag = std::make_shared<Robot>();
    ASSERT_EQ(AxisGroupMgr::instance().add_axisgroup(ag), 0);
    ASSERT_EQ(AxisGroupMgr::instance().del_axisgroup(1), -1);
    ASSERT_EQ(AxisGroupMgr::instance().del_axisgroup(0), 0);
}